package week1;

public class test4 {
    //构造方法的重载，只重载参数的个数，因为参数的类型已经确定了
    public static void main(String[] args) {
        Person per1=new Person("小熊");
        Person per2=new Person("小熊",18);
    }
}
    class Person {
        private String name;
        private int age;
        private String sex;
        public Person(String n){
            name=n;
            System.out.println("name="+name);
            System.out.println("Person的一个参数的有参构造");
        }
        public Person(String n,int a){
            name=n;
            age=a;
            System.out.println("name="+name+",age="+age);
            System.out.println("Person的两个参数的有参构造");
        }
    }